package astnode;

import java.util.ArrayList;

public class VariableDeclarationNode extends DeclarationNode{
	private ExpressionNode size = null;
	private ArrayList< VariableDeclarationNode > list = new ArrayList<VariableDeclarationNode >();
	private String position = "";
	private int sizeValue = 0;
	private boolean hasInit = false;
	
	public VariableDeclarationNode( int lineNum ) {
		super( lineNum );
	}
	public VariableDeclarationNode( DeclarationNode node ) {
		super(node);
	}
	public ExpressionNode getSize() {
		return size;
	}
	public void setSize(ExpressionNode size) {
		this.size = size;
	}
	
	public void addFollowVariableDeclaration( VariableDeclarationNode dec ){
		list.add( dec );
	}
	
	public ArrayList< VariableDeclarationNode > getFollowList(){
		return list;
	}
	
	@Override
	public String toString(){
		return "VariableDeclarationNode";
	}
	public String getPosition() {
		return position;
	}
	public void setPosition(String position) {
		this.position = position;
	}
	public int getSizeValue() {
		return sizeValue;
	}
	public void setSizeValue(int sizeValue) {
		this.sizeValue = sizeValue;
	}
	
	public int getTotalSizes(){
		int size = 0;
		for(int i=0; i<list.size(); i++){
			size = list.get(i).getSizeValue() + size;
		}
		size = size + this.getSizeValue();
		return size;
	}
	
	public boolean isArray(){
		return size!=null ;
	}
	
	public boolean hasInited() {
		return hasInit;
	}
	public void setHasInit(boolean hasInit) {
		this.hasInit = hasInit;
	}
}
